
class OrderService

  class << self

    def log_order_history order
      order.order_histories.build(
        status: order.current_state.to_s,
        amount: order.total_money
      )
      order.save!
    end

    def update_total_amount order, total_amount
      order.total_money = total_amount

      payment = order.payment

      payment.total_money = total_amount

      Order.transaction do
        order.save!
        payment.save!
      end
      true
    end

  end

end
